
/*******************************************************************************
 * Copyright (c) 2007 Jules White. All rights reserved.
 * This program and the accompanying materials are made available under the
 * terms of the Common Public License v1.0 which accompanies this distribution,
 * and is available at http://www.eclipse.org/legal/cpl-v10.html
 * 
 * Contributors: Jules White - initial API and implementation
 ******************************************************************************/
package org.refresh.prolog;

import java.nio.charset.Charset;

import sun.awt.datatransfer.DataTransferer.CharsetComparator;

public class PiD {
	private Charset cset_ = Charset.defaultCharset();

	public static String toPID(String id){
//		if(id == null)
//			return null;
//		
//		String pid = "";
//		
//		for(int i = 0; i < id.length(); i++){
//			if(Character.isLetterOrDigit(id.charAt(i))){
//				pid += id.charAt(i);
//			}
//			else{
//				int cv = (int)id.charAt(i);
//				pid += "_"+cv+"_";
//			}
//		}
//		
//		return pid;
		return id;
	}
	
	public static String toID(String id){
//		if(id == null)
//			return null;
//		
//		//remove id_
//		id = id.substring(3);
//		
//		String pid = "";
//		
//		for(int i = 0; i < id.length(); i++){
//			if(Character.isLetterOrDigit(id.charAt(i))){
//				pid += id.charAt(i);
//			}
//			else {
//				int end = id.indexOf("_",i+1);
//				String ccode = id.substring(i+1,end);
//				try{
//					char cval = (char)Integer.parseInt(ccode);
//					pid += cval;
//					i = end;
//				}catch (Exception e) {}
//			}
//		}
//		return pid;
		return id;
	}
	
	public static String toPID(ID id){
		return toPID(id.toString());
	}
}
